function [distance]=calc_decomp_dist(mult, position, total_installs_base,params, A_t, Nbar_i, HH_bin, CollPerc_t, Pol_t, Own_t, Inc_t, ...
Sunit_state, Skwh_state, Scost_state, P_state, P_sale_state, PIns_state,PIns0_state, ...
    Load, RenProd, PPRegion, PPRegion2, PPInt, PPCap, PPInf,PPRandStacked, ...
 ProdMedian,DamagesCoef1,DamagesCoef2, DamagesCoefPoll1,DamagesCoefPoll2, TractSunlightProfile)

run_damages=0;

if position==1
   Sunit_state=Sunit_state.*mult; 
   Skwh_state=Skwh_state.*mult; 
   Scost_state=Scost_state.*mult;
end

if position==2
   P_state=P_state.*mult; 
   P_sale_state=P_sale_state.*mult;
end

if position==3
    PIns_state=PIns_state.*mult;
    PIns0_state=PIns0_state.*mult;
end

if position==4
    A_t=A_t.*mult;
end

if position==5
    CollPerc_t=CollPerc_t.*mult;
    Pol_t=Pol_t.*mult;
    Own_t=Own_t.*mult;
    Inc_t=Inc_t.*mult;
end




    [M_sim,BI_sim, D_sim, DPol_sim, MargDamagesHour, M_bin_sim, pi_bin, Exp_sub_sim, Tot_ut_sim]=...
        simulate(params, A_t, Nbar_i, HH_bin, CollPerc_t, Pol_t, Own_t, Inc_t, ...
    Sunit_state, Skwh_state, Scost_state, P_state, P_sale_state, PIns_state,PIns0_state, ...
    Load, RenProd, PPRegion, PPRegion2, PPInt, PPCap, PPInf,PPRandStacked, ...
 ProdMedian,DamagesCoef1,DamagesCoef2, DamagesCoefPoll1,DamagesCoefPoll2, TractSunlightProfile, run_damages);

 

 total_installs_decomp=sum(BI_sim);
 
 
 distance=abs(log( total_installs_decomp)-log(total_installs_base));
